<!DOCTYPE html>
<html>
<#include "include/header.html"/>
<body id="vs">
	<div class="page">
		<div class="content">
			<img src="${ctx}/resource/images/banner.png" class="banner">
			<div class="wrap">
				<!-- 导航栏 -->
				<nav>
					<ul>
						<li><a href="${ctx}/home/homePage">返回首页</a></li>
						<li><a href="${ctx}/home/forwardExchang">拼手气</a></li>
					</ul>
				</nav>

				<div class="vs">
					<#if championCompetition ??> 
					<#if championUserGuessing ??>
					<#if championUserGuessing.team_type == '01'> 
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '01' > 
					    <a>
						<div class="left won" id="home_team" >
							<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					<#else>
						<a>
						<div class="left chosed" id="home_team" >
									<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if>
					<#else> 
					    <a>
						<div class="left chosed" id="home_team" >
											<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if>
					<#else> 
					   <#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '01' > 
					    <a>
						<div class="left won" id="home_team" >
							<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					<#else>
						<a>
						<div class="left" id="home_team" >
									<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if>
					<#else> 
					    <a>
						<div class="left" id="home_team" >
					</#if>
					</#if> 
					<#else> 
					<#if championCompetition.competition_status == '01' && championCompetition.is_guess == '1' > 
					    <a onclick="selectTeam('${championCompetition.home_team!}','01','${championCompetition.home_odds!}');">
					<#else> 
					    <a> 
					</#if> 
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '01' >
						<div class="left won" id="home_team" >   <!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					<#else>
						<div class="left " id="home_team" >
																	<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if> 
					<#else>
						<div class="left " id="home_team" >
																		<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if>
					</#if>
						<div class="pic" style="background-image: url('${server_uri!}${championCompetition.home_team_pic!}');"></div>
						<img src="${ctx}/resource/images/vs/team_star.png">
						<div class="ratio">赔率${championCompetition.home_odds!}</div>
						<div class="cover"></div>
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '01' >
						<div class="win-cover"> <img src="${ctx}/resource/images/vs/win.png">
						<div class="ratio">赔率${championCompetition.home_odds!}</div>
						</div>
					</#if> 
					</#if>
					
						</div>
						</a>
						<div class="center"> <img src="${ctx}/resource/images/vs/center.png">
						
						</div> 
					</#if> 
					<#if championCompetition ??> 
					<#if championUserGuessing ??> 
					<#if championUserGuessing.team_type == '02'> 
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '02' > 
					    <a>
						<div class="right won" id="visit_team">
																<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					<#else> 
					    <a>
						<div class="right chosed" id="visit_team">
																		<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if> 
					<#else> 
					    <a>
						<div class="right chosed" id="visit_team">
																				<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if> 
					<#else> 
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '02' > 
					    <a>
						<div class="right won" id="visit_team">
																<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					<#else> 
					    <a>
						<div class="right " id="visit_team">
																		<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if> 
					<#else> 
					    <a>
						<div class="right " id="visit_team">
																				<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if> 
					</#if> 
					<#else> 
					<#if championCompetition.competition_status == '01' && championCompetition.is_guess == '1'> 
					    <a onclick="selectTeam('${championCompetition.visiting_team!}','02','${championCompetition.visiting_odds!}');">
					<#else> 
					    <a> 
					</#if> 
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '02' >
						<div class="right won" id="visit_team">
																									<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					<#else>
						<div class="right " id="visit_team">
																										<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if> 
					<#else>
						<div class="right " id="visit_team">
																											<!--当前选中的队伍有class：chosed; 获胜的队伍有class：won-->
					</#if>
					</#if>
						<div class="pic" style="background-image: url('${server_uri!}${championCompetition.visiting_team_pic!}');"></div>
						<img src="${ctx}/resource/images/vs/team_champian.png">
						<div class="ratio">赔率${championCompetition.visiting_odds!}</div>
						<div class="cover"></div>
					<#if championCompetition.winner ?? > 
					<#if championCompetition.winner == '02' >
						<div class="win-cover">
						<img src="${ctx}/resource/images/vs/win.png">
						<div class="ratio">赔率${championCompetition.visiting_odds!}</div>
						</div>
					</#if> 
					</#if>
						</div>
						</a> 
						
						<img src="${ctx}/resource/images/vs/desc.png" class="desc" alt=""> 
					</#if>
					
					
						</div>
						<#if championCompetition.competition_status == '01' >
					<#if championUserGuessing ??>
					<div class="op" >
						<div class="support">
						支持活力币：<input type="number" disabled="true" value="${championUserGuessing.pay_currency!}">
						<img src="${ctx}/resource/images/vs/icon_flash.png">
						</div> 
					<#else> 
					<#if championCompetition.is_guess == '1'>
					<div class="op" >
					<div class="support">
					        支持活力币：<input type="number" id="pay_num"><img src="${ctx}/resource/images/vs/icon_flash.png">
						</div> 
						</#if> 
						</#if> 
						<#else> 
						
						<#if championUserGuessing ??>
						<div class="op" >
						<div class="support">
						支持活力币：<input type="number" disabled="true" value="${championUserGuessing.pay_currency!}">
						<img src="${ctx}/resource/images/vs/icon_flash.png">
						</div> 
					</#if> 
					</#if>
					<#if championCompetition.competition_status == '04' >
						<div class="bottom has-result">
						<#else>
						<#if championCompetition.competition_status == '01' >
					<#if championCompetition.is_guess == '1' >
					<#if championCompetition.countNum == 0 >
						<div class="bottom ">
					</#if>
					</#if>
					</#if>
					</#if>
					<#if championUserGuessing ??>
					<#if championUserGuessing.win_currency ??>
						<div class="result">
						获得活力币：<input type="number" disabled="true" value="${championUserGuessing.win_currency!}">
						<img src="${ctx}/resource/images/vs/icon_flash_blue.png">
						</div>
						</div>
					</#if> 
					</#if> 
					<#if championCompetition.competition_status == '01' >
					<#if championCompetition.is_guess == '1' >
					<#if championCompetition.countNum == 0 >
					    <img src="${ctx}/resource/images/vs/btn.png" class="submit" onclick="submitSguess('${championCompetition.id!}')">
					    </div>
					</#if> 
					</#if> 
					</#if> 
						</div>
																								<!-- 提交成功 -->
																								<div class="dialog sub-success">
																									<div class="d-body"></div>
																									<div class="d-footer">
																										<img
																											src="${ctx}/resource/images/index/dialog_btn_back.png"
																											class="btn one back" alt=""
																											onclick="dialogSugessClose()">
																										<!--返回按钮-->
																									</div>
																								</div>

																								<!-- 提交失败 -->
																								<div class="dialog sub-fail">
																									<div class="d-body" id="sub-fail-message">
																										<p class="message">系统繁忙 请稍后再试</p>
																									</div>
																									<div class="d-footer">
																										<img
																											src="${ctx}/resource/images/index/dialog_btn_back.png"
																											class="btn one back" alt=""
																											onclick="dialogClose()">
																										<!--返回按钮-->
																									</div>
																								</div>
																							</div>
																					</div>
																					<div class="mask"></div>
</body>
<script type="text/javascript">
	var team_id = "";
	var team_type = "";
	var team_odds = "";
	function selectTeam(teamId, teamType, odds) {
	    
	    $("#visit_team").removeClass("chosed");
	    $("#home_team").removeClass("chosed");
	    if(teamType == '01'){
	    $("#home_team").addClass("chosed");
	    }else{
	    $("#visit_team").addClass("chosed");
	    }
	    
		team_id = teamId;
		team_type = teamType;
		team_odds = odds;
	}
	function dialogSugessClose() {
		window.location.href = window.location.origin
				+ window.location.pathname + window.location.search;
	}
	function submitSguess(competition_id) {
		if (team_id == "" || team_type == "" || team_odds == "") {
			var warningHtm = "<p class='message'>请选择一个队伍进行竞猜</p>";
			$("#sub-fail-message").html(warningHtm);
			dialog(".sub-fail");
			return;
		}
		var currency_num = $("#pay_num").val();
		if (currency_num == "") {
			var warningHtm = "<p class='message'>活力币不能为空</p>";
			$("#sub-fail-message").html(warningHtm);
			dialog(".sub-fail");
			return;
		}
		$.post("${ctx}/home/guessCompetition", {
			competition_id : competition_id,
			team_id : team_id,
			team_type : team_type,
			pay_odds : team_odds,
			pay_currency : currency_num
		}, function(data) {
			if (data.code == 0) {
				dialog(".sub-success");
			} else {
				var msgHtm = "<p class='message'>" + data.msg + "</p>";
				$("#sub-fail-message").html(msgHtm);
				dialog(".sub-fail");
			}
		});
	}
</script>
</html>